#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>

#define info(...) printk("<1> info " __VA_ARGS__)

int count = 0;

static ssize_t my_write (struct file *f, const char __user *data, size_t len, loff_t *loff)
{
  int *p = *((int **)data);
  int a;
  (*p )++;
  a = *p;
  printk("%d", a);
  ++count;
  return len;
}


static int my_open(struct inode *in, struct file *f)
{
  return 0;
}



struct file_operations my_fo = {
  open: my_open,
  write: my_write
};



static int my_init(void)
{
  int n;
  if((n = register_chrdev(0, "exam_chr_dev", &my_fo)) < 0)
    info("very bad");
  info("init, %d", n);
  
  return 0;
}



static void my_exit(void)
{
  info("exit %d", count);
}


module_init(my_init);
module_exit(my_exit);